import { request } from '@/utils/request';

// 查询工单信息（受理单）列表
export function listWorkOrder(query) {
  console.log(query);
  
  return request({
    url: '/workorder/woWorkOrder/list?page='+ query.page + '&limit=' + query.limit,
    method: 'POST',
    data: query,
  });
}

// 查询未处结工单信息（受理单）列表
export function listWorkOrderNoEnd(query) {
  return request({
    url: '/workorder/woWorkOrder/listNoEnd?page='+ query.page + '&limit=' + query.limit,
    method: 'POST',
    data: query,
  });
}

// 查询工单信息（受理单）详细
export function getWorkOrder(id) {
  return request({
    url: '/workorder/woWorkOrder/' + id,
    method: 'get',
  });
}

// 查询工单信息（受理单）详细（通过工单单号查询）
export function getWorkOrderByWorkOrderNumber(workOrderNumber) {
  return request({
    url: '/workorder/woWorkOrder/workOrderNumber/' + workOrderNumber,
    method: 'get',
  });
}

// 新增工单信息（受理单）
export function createWorkOrder(data) {
  return request(
    {
      url: '/workorder/woWorkOrder',
      method: 'post',
      data: data,
    },
    {
      successMsg: '添加成功！',
    },
  );
}

// 修改工单信息（受理单）
export function updateWorkOrder(data) {
  return request(
    {
      url: '/workorder/woWorkOrder',
      method: 'put',
      data: data,
    },
    {
      successMsg: '保存成功！',
    },
  );
}

// 删除工单信息（受理单）
export function deleteWorkOrder(id) {
  return request({
    url: '/workorder/woWorkOrder/' + id,
    method: 'delete',
  });
}

// 初始化是设置工单单号  受理时间  受理单号等信息
export function getInitWorkOrder() {
  return request({
    url: '/workorder/woWorkOrder/getInitWorkOrder',
    method: 'get',
  });
}

// 进行派单处理
export function dispatchWorkOrder(params: any) {
  return request(
    {
      url: '/workorder/woWorkOrder/dispatchWorkOrder',
      method: 'post',
      data: params,
    },
    {
      successMsg: '派单成功！',
    },
  );
}

// 工单转派
export function sendLastWorkOrder(params: any) {
  return request(
    {
      url: '/workorder/woWorkOrder/sendLastWorkOrder',
      method: 'post',
      data: params,
    },
    {
      successMsg: '操作成功！',
    },
  );
}

export function changeMergeWorkOrderHandle(params: any) {
  return request(
    {
      url: '/workorder/woWorkOrder/changeMergeWorkOrderHandle',
      method: 'post',
      data: params,
    },
    {
      successMsg: '操作成功！',
    },
  );
}

// 并单查询列表
export function listWorkOrderMerge(query) {
  return request({
    url: '/workorder/woWorkOrder/listMerge',
    method: 'get',
    params: query,
  });
}
